package Function.ItemUse;

import FCRendering.FCRMaster;
import VWorldGameStudio.*;

import static FCRendering.FCRMaster.fcv;

public class ToolHuaBan extends AItemUse{
    @Override
    public ItemUseResult directUse() {
        return useForTankTarget(keepItemTank);
    }

    @Override
    public ItemUseResult useInMapTarget(int x, int y) {
        return useForTankTarget(keepItemTank);
    }

    @Override
    public ItemUseResult useForMonsterTarget(FCBattleOrder battleOrder, FCMonster m) {
        return new ItemUseResult().useless();
    }

    @Override
    public ItemUseResult useForPlayerTarget(FCPlayerInfo p) {
        return new ItemUseResult().useless();
    }

    @Override
    public ItemUseResult useForTankTarget(FCTank t) {
        if(t == null){
            return new ItemUseResult().useless();
        }
        fcv.closeAllShowWindw();
        if(!useItem.getEnableOccupation().contains(keepPlayer.getOccupation())){
            fcv.getMessage().add("仅限机械职业使用！");
            fcv.showMessage();
            return new ItemUseResult().useless();
        }
        ItemUseResult result = new ItemUseResult();
        FCItem fixIt = t.findTheMaxLowDefenseItem();
        int allDefens = fixIt.getDefenseAdd()+fixIt.getDefenseUpgradeAdd();
        if(fixIt.getCurrentDefense() != allDefens){
            fixIt.setCurrentDefense(allDefens);
            result.resultString.add("把 "+ fixIt.getChName()+" 修复了");
            fcv.getMessage().add("把 "+ fixIt.getChName()+" 修复了");
            fcv.showMessage();
            useAfter();
        }else {
            result.resultString.add("你的坦克不需要修理！");
            fcv.getMessage().add("你的坦克不需要修理！");
            fcv.showMessage();
        }
        return result;
    }
}
